package edu.moravian.managers;

import edu.moravian.entity.Tower;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 *
 * @author ronaghan
 */
public class TowerManager
{
    private List<Tower> towers;
    
    public TowerManager()
    {
        towers = new CopyOnWriteArrayList<Tower>();
    }
    
    public synchronized void addTower(Tower tower)
    {
        towers.add(tower);
    }
    
    public synchronized void removeTower(Tower tower)
    {
        towers.remove(tower);
    }
    
    public synchronized Iterable<Tower> getTowers()
    {
        return Collections.unmodifiableList(towers);
    }
    
    public synchronized void update(double delta, OrdinanceManager ordinanceManager, EnemyManager enemyManager)
    {
        for(Tower tower: towers)
        {
            tower.update(delta, ordinanceManager, enemyManager);
        }
    }
}
